package com.ph.custom.processor.handler;

import java.lang.reflect.Proxy;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.ph.custom.cache.service.UserCacheDataService;
import com.ph.custom.cache.service.CustomTokenService;
import com.ph.custom.processor.CacheDataProcessor;
import com.ph.custom.processor.UserCacheAnnotationProcessor;
import com.ph.custom.processor.UserCacheProcessor;

@Configuration
public class CustomBeanConfig {

	/**
	 * 
	 * @Title: userCacheProcessor   
	 * @Description: 缓存注解处理   
	 * @param: @return      
	 * @return: UserCacheAnnotationProcessor      
	 * @throws
	 */
	@Bean
	public UserCacheAnnotationProcessor userCacheAnnotationProcessor() {

		return new AnnotationProcessorHandler();
	}
	/**
	 * 
	 * @Title: cacheDataProcessor   
	 * @Description: 使用代理处理缓存   
	 * @param: @return      
	 * @return: CacheDataProcessor      
	 * @throws
	 */
	@Bean
	public CacheDataProcessor cacheDataProcessor() {

		return (CacheDataProcessor) Proxy.newProxyInstance(CacheDataProcessor.class.getClassLoader(),
				new Class[] { CacheDataProcessor.class }, new CacheSelector(new UserCacheDataService()));
	}
	/**
	 * 
	 * @Title: userCacheProcessor   
	 * @Description: 缓存处理 
	 * @param: @return      
	 * @return: UserCacheProcessor      
	 * @throws
	 */
	@Bean
	public UserCacheProcessor userCacheProcessor() {

		return new CacheProcessorHandler();
	}
	/**
	 * 
	 * @Title: customTokenService   
	 * @Description: token service   
	 * @param: @return      
	 * @return: CustomTokenService      
	 * @throws
	 */
	@Bean
	public CustomTokenService customTokenService(){
		
		return new CustomTokenService();
	}
}
